package com.snailhd.listener;

import com.snailhd.constant.ListenerEnums;
import com.snailhd.entity.StockRealTime;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author hd
 * @date 2019-11-24 18:26
 */

@Component
public class StockRealTimeListener implements Listener<List<StockRealTime>> {

    @Resource
    ListenerManager listenerManager;

    @Override
    public void monitor(List<StockRealTime> stockRealTimes) {
        for (Listener listener : listenerManager.getListener(ListenerEnums.STOCK_REAL_TIME)){
            ListenerManager.executor.execute(new Runnable() {
                @Override
                public void run() {
                    listener.monitor(stockRealTimes);
                }
            });
        }
    }
}
